package com.videoanswer.van.web.client.utils;

import java.util.List;

public class Pager {

	private int totalCount;
	private int firstIndex;
	private int lastIndex;
	private int perPageCount;
	private int totalPage;
	private int currentPage;
	private List datas;

	public int getPerPageCount() {
		return perPageCount;
	}

	public void setPerPageCount(int perPageCount) {
		this.perPageCount = perPageCount;
	}

	public int getFirstIndex() {
		return this.perPageCount * this.getCurrentPage();
	}

	public void setFirstIndex(int firstIndex) {
		this.firstIndex = firstIndex;
	}

	public int getLastIndex() {
		return lastIndex;
	}

	public void setLastIndex(int lastIndex) {

		this.lastIndex = lastIndex;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getTotalPage() {

		return totalCount % this.perPageCount == 0 ? totalCount
				/ this.perPageCount : totalCount / this.perPageCount + 1;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public int getCurrentPage() {

		if ((this.currentPage+1) > this.getTotalPage()) {
			return this.getTotalPage()-1;
		}
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public List getDatas() {
		return datas;
	}

	public void setDatas(List datas) {
		this.datas = datas;
	}

}
